lower = input("Enter lower bound: ")
while not lower.isdigit():
    print("Invalid input. Try again")
    lower = input("Enter lower bound: ")


upper = input("Enter upper bound: ")
while not upper.isdigit():
    print("Invalid input. Try again")
    upper = input("Enter upper bound: ")

lower = int(lower)
upper = int(upper)

while lower > upper:
    print("Lower bound cannot be greater than upper bound.")
    print()
    lower = input("Enter lower bound: ")
    while not lower.isdigit():
        print("Invalid input. Try again")
        lower = input("Enter lower bound: ")


    upper = input("Enter upper bound: ")
    while not upper.isdigit():
        print("Invalid input. Try again")
        upper = input("Enter upper bound: ")

    lower = int(lower)
    upper = int(upper)





print("\n"*3)
print(" "*6, end="")

for i in range(lower, upper+1):
    print("%4d" % i, end="")
print()

print(" "*7, end="")

for i in range(lower, upper+1):
    print("----", end="")
print()


for i in range(lower, upper+1):
    print("%-4d: " % i, end="")
    ######
    for j in range(lower, upper+1):
        print("%4d" % (i*j), end="")
    print()




